/**
 * Created by Administrator on 2017/4/5.
 */

$(function(){
    var indextype =[
        {"value":1,"text":"全文"},
        {"value":2,"text":"职位"},
        {"value":3,"text":"公司"}
    ]
    //indextype.option.unshift({"value":8,"text":"请选","selected":true})
    $("#keyword_type").select({
        optionData:indextype,
        css:'indexOptions',
        //selectWidth: 300,//菜单按扭的宽
        //selectHeight: 80,//菜单按扭的高
        offset:Array(-2,-1),
        callback:function(){
            
        }
    });

    //更多搜索选项
    $(".logoAndNav .others div a").on("mouseenter",function(){
        $(this).next().show().on("mouseleave",function(){
            $(this).hide();
        });
        $(this).on("mouseleave",function(){
            $(this).next().hide().on("mouseenter",function(){
                $(this).show();
            });
        });
    });
});

//检查个人用户登录
function checkPersonal(oForm){
    var username = str_trim($(oForm).find('#username').val());
    if(username == ''){
        layer.msg("用户名/手机号码不能为空!",{icon:5,time:2000});
        $(oForm).find('#username').focus();
        $(oForm).find('#username').val(username);
        return false;
    }
    if($(oForm).find('#password').val() == '' ||  $(oForm).find('#password').val().length < 6  ){
        layer.msg("密码不能为空,或者密码长度不能少于6位!",{icon:5,time:2000});
        $(oForm).find('#password').focus();
        return false;
    }
    var queryString = $(oForm).formSerialize();
    $.ajax({
        url: '/personal/ajax_login',
        dataType: "json",
        data: queryString,
        type: "POST",
        success: function (data) {
            if(data.status == '0'){
                layer.msg(data.msg, {icon: 6});
                location = welcomeUrl;
            }else{
                layer.msg(data.msg, {icon: 5});
            }
        },
        error: function (data) {
            var msgErr='';
            var errors = $.parseJSON(data.responseText);
            $.each(errors, function(index, value) {
                msgErr +=  value+";<br>";
            });
            layer.msg(msgErr, {icon: 5});
        },
        complete: function () {
        }
    });
    return false;
}

//检查企业用户登录
function checkCompany(oForm){
    var username = str_trim($(oForm).find('#username').val());
    if(username == ''){
        layer.msg("用户名不能为空!",{icon:5,time:2000});
        $(oForm).find('#username').focus();
        $(oForm).find('#username').val(username);
        return false;
    }
    if($(oForm).find('#password').val() == '' ||  $(oForm).find('#password').val().length < 6  ){
        layer.msg("密码不能为空,或者密码长度不能少于6位!",{icon:5,time:2000});
        $(oForm).find('#password').focus();
        return false;
    }
    var queryString = $(oForm).formSerialize();
    $.ajax({
        url: '/company/ajax_company_login',
        dataType: "json",
        data: queryString,
        type: "POST",
        success: function (data) {
            if(data.status == '0'){
                layer.msg(data.msg, {icon: 6});
                location = companyWelcomeUrl;
            }else{
                layer.msg(data.msg, {icon: 5});
            }
        },
        error: function (data) {
            var msgErr='';
            var errors = $.parseJSON(data.responseText);
            $.each(errors, function(index, value) {
                msgErr +=  value+";<br>";
            });
            layer.msg(msgErr, {icon: 5});
        },
        complete: function () {
        }
    });
    return false;
}
